<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Property_mdl extends CI_Model{
    function __construct(){
        parent::__construct();
        $this->load->database();
    
    }
    
	public function getListProperty(){
		$this->db->select('ID_PROPERTI ,
							  ID_LOKASI ,
							  JENIS ,
							  ID_CLASS ,
							  HARGA_JUAL ,
							  LUAS_BANGUNAN,
							  LUAS_TANAH,
							  TANAH_HOOK,
							  JL_LANTAI ,
							  ARAH_POSISI,
							  CLUSTER,
							  NAMA_BLOK ,
							  NO_PROPERTI ,
							  NO_SERTIFIKAT ,
							  JNS_SERTIFIKAT ,
							  STATUS ,
							  RENCANA_TGL_MULAI,
							  RENCANA_TGL_SELESAI,
							  AKTUAL_TGL_MULAI ,
							  AKTUAL_TGL_SELESAI  ,
							  PROGRESS_PEMBANGUNAN ,
							  PICTURE ,
							  DT_STAMP ,
							  UPDATE_ID ');
		$this->db->from('t_properti');
		$query=$this->db->get();
		$rows=$query->result();
		if($query->num_rows > 0){
			foreach($rows as $row)
				$data[] = Array(
					  'id_properti'=>$row->ID_PROPERTI,
					  'id_lokasi'=>$row->ID_LOKASI,
					  'jenis'=>$row->JENIS,
					  'id_class'=>$row->ID_CLASS,
					  'harga_jual'=>$row->HARGA_JUAL,
					  'luas_bangunan'=>$row->LUAS_BANGUNAN,
					  'luas_tanah'=>$row->LUAS_TANAH,
					  'tanah_hook'=>$row->TANAH_HOOK,
					  'jl_lantai'=>$row->JL_LANTAI,
					  'arah_posisi'=>$row->ARAH_POSISI,
					  'cluster'=>$row->CLUSTER,
					  'nama_blok'=>$row->NAMA_BLOK,
					  'no_properti'=>$row->NO_PROPERTI,
					  'no_sertifikat'=>$row->NO_SERTIFIKAT,
					  'jns_sertifikat'=>$row->JNS_SERTIFIKAT,
					  'status'=>$row->STATUS,
					  'rencana_tgl_mulai'=>$row->RENCANA_TGL_MULAI,
					  'rencana_tgl_selesai'=>$row->RENCANA_TGL_SELESAI,
					  'aktual_tgl_mulai'=>$row->AKTUAL_TGL_MULAI,
					  'aktual_tgl_selesai'=>$row->AKTUAL_TGL_SELESAI,
					  'progress_pembangunan'=>$row->PROGRESS_PEMBANGUNAN,
					  'picture'=>$row->PICTURE,
					  'dt_stamp'=>$row->DT_STAMP,
					  'update_id'=>$row->UPDATE_ID
			);
			
			return $data;
		}
		return null;
	}
	
	public function SaveAdd($data){
		return $this->db->insert('t_properti',$data);
	}
	
	public function SaveEdit($data){
		$where=Array('id_properti'=>$data->id_properti,'id_lokasi'=>$data->id_lokasi);
		return $this->db->update('t_properti', $data, $where);
		
	}
	
	public function Delete($id_properti,$id_lokasi){
		$where=Array('id_properti'=>$id_properti,'id_lokasi'=>$id_lokasi);
		return $query=$this->db->delete('t_properti',$where);
		
	}
	
}	
?>